array contains case insensitive javascript

69

array contains case insensitive javascript -

var array = ['I', 'hAve', 'theSe', 'ITEMs'],
    query = 'these',
    result = array.findIndex(item => query.toLowerCase() === item.toLowerCase());

console.log(result); // 2

Comments

Submit
0 Comments